﻿using Habi.Solver.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Habi.Solver.Models
{
    public class AppModel
    {

        private static int INDEX = 1;
        static AppModel()
        {
            INDEX = 1;
        }


        [Display(AutoGenerateField = false)]
        public string Key
        {
            get
            {
                return (INDEX++).ToString();
            }
        }
        [Display( AutoGenerateFilter = true)]
        public string Name { get; set; }

        [Display(AutoGenerateField = false)]
        public Icon Icon
        {
            get
            {
                if (!string.IsNullOrEmpty(IconPath))
                {
                    string path = RegexHelper.MatchRegUninstallPath(IconPath);
                    return SystemEnvHelper.FileIcon.GetIcon(path, true);
                }
                return null;
            }
        }

        [Display(AutoGenerateField = false)]
        public string IconPath { get; set; }
        public string Path { get; set; }

        [Display(AutoGenerateField = false)]
        public string UnInstallPath { get; set; }

        public string Version { get; set; }
        public string Publisher { get; set; }

        [DataType(DataType.Url)]
        public string AboutInfo { get; set; }

        [DataType(DataType.DateTime)]
        public DateTime? InstallDate { get; set; }

        [DataType(DataType.DateTime)]
        public DateTime? LastOperatTime { get; set; }

        [Display(Name = "Runing")]
        public int OnLine { get; set; }
    }
}
